const Base = require('./base.js');

module.exports = class extends Base {
  async getRuleAction() {
    const data = await this.model('text')
      .where({ id: this.get('id') })
      .find();
    return this.success(data);
  }

  async addRuleAction() {
    const values = this.post();
    const id = this.post('id');
    const model = this.model('text');

    if (id > 0) {
      await model
        .where({
          id: id,
        })
        .update(values);
    }

    return this.success(values);
  }
};
